﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Helpers;

namespace myMvcBlog.Controllers
{
    /// <summary>
    /// This is the controller for ajax calls, which means it will not return a view
    /// </summary>
    public class APIController : Controller
    {
        //
        // GET: /API/

        public JsonResult AddComment(Comment comment, long postid)
        {
            comment.IP = Request.UserHostAddress;
            comment.CommentTime = DateTime.Now;
            comment.PostID = postid;

            comment.Save();
            return Json(new { author = comment.Author, email = comment.Email },
                JsonRequestBehavior.AllowGet);
        }

    }
}
